package main

import (
	"fmt"
	"reflect"
)

type Animal interface {
	shout() string
	eat()
}
type Dog struct {
	Name string
}

func (self Dog) shout() string {
	return fmt.Sprintf("wang wang")
}
func (self *Dog) eat() {
	fmt.Println("eating meat....")
}

type Cat struct {
}

func (self Cat) shout() string {
	return fmt.Sprintf("miao miao")
}
func (self *Cat) eat() {
	fmt.Println("eating fish....")
}

func main() {
	var animal Animal = &Dog{}
	animal.eat()
	fmt.Println(reflect.TypeOf(animal))
	switch a := animal.(type) {
	case *Dog:
		fmt.Println("Dog", a.shout(), a.Name)
	case *Cat:
		fmt.Println("Cat", a.shout())
	}
}
